# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=roputils
pkgver=195.ae7ed20
pkgrel=4
groups=('blackarch' 'blackarch-exploitation')
pkgdesc='A Return-oriented Programming toolkit.'
arch=('any')
url='https://github.com/inaz2/roputils'
license=('custom:unknown')
depends=('python2')
makedepends=('git')
source=("git+https://github.com/inaz2/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  find "$srcdir" -name "*.py" -exec sed -i '1s|env python|env python2|' {} \;
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  chmod +x "$pkgdir/usr/share/$pkgname/roputils.py"

  ln -s "/usr/share/roputils/$pkgname.py" "$pkgdir/usr/bin/$pkgname"
}

